package util.concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author Khai Loon
 * @since 2018/5/22
 */
public class Callable_ {


    public static void main(String[] args)  {


        Callable<String> callable = () -> Thread.currentThread().getName() + System.currentTimeMillis();

        FutureTask<String> futureTask = new FutureTask<>(callable);


        new Thread(futureTask).start();

        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
        }

        try {
            System.out.println("异步获取值 " + futureTask.get());
        } catch (InterruptedException e) {
        } catch (ExecutionException e) {
            System.out.println();
        }
    }

}
